#include <iostream>

template <class T>
struct __list_node
{
    T _data;
    __list_node* _next;
    __list_node* _prev;
    __list_node(T data = T(),__list_node* next = nullptr,__list_node* prev = nullptr)
    :_data(data),_next(next),_prev(prev)
    {}
};

template<class T>
class my_list
{
    public:
        using Node = __list_node<T>;
    private:
        __list_node<T>* _head = nullptr;
    public:
        my_list(){empty_init();}
        void Print()
        {
            __list_node<T>* cur = _head -> _next;
            while(cur != _head)
            {
                std::cout << cur->_data << " ";
                cur = cur->_next;
            }
            std::cout << std::endl;
        }
        void empty_init()
        {
            _head = new __list_node<T>; 
            _head->_next = _head;
            _head->_prev = _head;
        }
        //头插
        void push_front(T x)
        {
            __list_node<T>* newNode = new __list_node<T>(x);
            newNode->_next = _head->_next;
            _head->_next = newNode;
            newNode->_prev = _head;
            newNode->_next->_prev = newNode;
        }
        //头删
        void pop_front()
        {
            if(_head->_next == _head) return;
            Node* cur = _head->_next;
            Node* next = cur->_next;
            _head->next = next;
            next->_prev = _head;
            delete cur;
            cur = nullptr;
        }

};